---
title: Agentica > Tutorial > Google Search Agents
---

## Introduction

- [playground](https://stackblitz.com/~/github.com/wrtnlabs/agentica-tutorial-google-search?file=README.md) You can see the demo code on the playground.

Set up a **fully functional Google Search Agent** powered by OpenAI's GPT model quickly using the Agentica CLI.

## Quick CLI Setup

Start the Agentica Setup Wizard with this single command:

```bash
npx agentica start google-search-agent
```

The wizard guides you through:

- Installing required packages (e.g., agentica@0.12.14)
- Choosing your package manager and project type
- Selecting the **GOOGLE SEARCH** controller
- Entering your `OPENAI_API_KEY`

Once complete, Agentica automatically generates your code, creates a `.env` file, and installs all dependencies.

## Generated Code Overview

The generated code looks like this:

```typescript
import { Agentica } from "@agentica/core";
import typia from "typia";
import dotenv from "dotenv";
import { OpenAI } from "openai";

import { GoogleSearchService } from "@wrtnlabs/connector-google-search";

dotenv.config();

export const agent = new Agentica({
  model: "chatgpt",
  vendor: {
    api: new OpenAI({
      apiKey: process.env.OPENAI_API_KEY!,
    }),
    model: "gpt-4o-mini",
  },
  controllers: [
    {
      name: "GoogleSearch Connector",
      protocol: "class",
      application: typia.llm.application<GoogleSearchService, "chatgpt">(),
      execute: new GoogleSearchService(),
    },
  ],
});

const main = async () => {
  console.log(await agent.conversate("What can you do?"));
};

main();
```

This code instantly sets up your Google Search Agent, ready to perform intelligent search queries on Google.

## What This Does

Your Google Search Agent will:

- **Process Google Search Data:** Use the `GoogleSearchService` connector.
- **Leverage OpenAI's GPT Model:** For smart search queries.
- **Maintain Type Safety:** With `typia`.
- **Securely Manage Credentials:** Using environment variables via `dotenv`.

Set up your environment variables in a `.env` file:

```env
OPENAI_API_KEY=your-openai-api-key
SERPAPI_API_KEY=your-serp-api-api-key
```

Make sure to include your SerpApi API key in the `SERPAPI_API_KEY` field.

## Use Case Example

Imagine asking the agent:

> "Find the best pizza places in New York City with outdoor seating"

The agent will search Google for top-rated pizza restaurants in New York City that offer outdoor seating, and provide you with relevant information on locations, ratings, reviews, and features.

## Available Functions

For a complete list of functions available in `GoogleSearchService`, check out the source code:  
👉 [wrtnlabs/connectors - GoogleSearchService.ts](https://github.com/wrtnlabs/connectors/blob/main/packages/google_search/src/google_search/GoogleSearchService.ts)

Your AI-powered Google Search Agent is now ready for seamless, automated search queries! 🚀
